<template>
  <el-dialog
    :visible.sync="dialogVisible"
    append-to-body
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    :show-close="false"
    title="标签停用理由"
    class="tag-edit-dialog information-modify-dialog"
    width="25%"
    v-dialogMove
  >
    <el-form :model="editForm" label-width="0" :rules="editFormRules" ref="editForm">
      <el-form-item prop="modifyReason">
        <el-input
          placeholder="请输入标签停用理由"
          v-model="editForm.modifyReason"
          type="textarea"
          :maxlength="100"
          :rows="5"
          :show-word-limit="true"
        ></el-input>
      </el-form-item>
    </el-form>
    <el-row>
      <el-col align="right">
        <el-button @click="handleCancel">取消</el-button>
        <el-button type="primary" @click="confirm">确定</el-button>
      </el-col>
    </el-row>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      dialogVisible: false,
      editForm: {
        modifyReason: ''
      },
      editFormRules: {
        modifyReason: [{ required: true, message: '标签停用理由不能为空', trigger: 'blur' }]
      }
    }
  },
  methods: {
    showDialog() {
      this.dialogVisible = true
    },
    confirm() {
      this.$refs.editForm.validate(valid => {
        if (valid) {
          this.$emit('callback', this.editForm.modifyReason)
          this.beforClose()
        }
      })
    },
    handleCancel() {
      this.$emit('cancel')
      this.beforClose()
    },
    clearForm() {
      this.editForm.modifyReason = ''
      this.$refs.editForm.clearValidate()
    },
    beforClose() {
      this.clearForm()
      this.dialogVisible = false
    }
  }
}
</script>

<style lang="scss"></style>
